# Maintainer: Milan P. Stanić <mps@arvanta.net>
pkgname=fwknop
pkgver=2.6.10
pkgrel=0
pkgdesc="A Single Packet Authorization (SPA) implementation"
url="http://www.cipherdyne.org/fwknop/"
arch="all"
license="GPL-2.0-or-later"
depends="iptables"
makedepends="libpcap-dev gpgme-dev"
subpackages="$pkgname-dev $pkgname-doc $pkgname-libs $pkgname-openrc $pkgname-server"
source="http://cipherdyne.org/fwknop/download/fwknop-$pkgver.tar.gz
	fwknopd.initd"

build() {
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--sysconfdir=/etc \
		--mandir=/usr/share/man \
		--infodir=/usr/share/info \
		--localstatedir=/var \
		--disable-static \
		--with-gpgme
	make
}

check() {
	make check
}

package() {
	make DESTDIR="$pkgdir" install
	install -Dm755 "$srcdir"/fwknopd.initd "$pkgdir"/etc/init.d/fwknopd
	cat <<- __EOF__ >> "$pkgdir"/etc/fwknop/access.conf
	\# If using gnupg2 see https://www.gnupg.org/faq/GnuPG-FAQ.html#how-can-i-use-gnupg-in-an-automated-environment & sign the client public key on the server with a normal key which has a password"
	\# disable GPG_DECRYPT_PW & enable the following variable:
	\#GPG_ALLOW_NO_PW: Y;
	__EOF__
}

server() {
	pkgdesc="A Single Packet Authorization (SPA) server"
	mkdir -p "$subpkgdir"/usr
	mv "$pkgdir"/usr/sbin "$subpkgdir"/usr/ \
		&& mv "$pkgdir"/etc "$subpkgdir"/
}

sha512sums="3b3e35eda574abd1759431c88677eea7078c54cb3252c0ee0e1019b5b8224ed8844d30760da70a952e1cd92b04715a547f6effabda54678f791fff9afa32cd80  fwknop-2.6.10.tar.gz
e3558c4a1579ea66b19451acc476f3cfec782b052f6d96a57ffc520169db755739e2bf3a815802cc5958a7b2fdeb9b39cf2182e5d89882cf4502985401352465  fwknopd.initd"
